﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
    <script src="https://cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
    <title></title>
</head>
<body>
<button type="button" id="getcard">领取卡券</button>

<button type="button" id="getcarda">获取已存在的卡券</button>
<script>
        $(function () {
            $.get('/api/wx/GetJsParam?url=' + location.href + '&debug=true',
                function (res) {
                    var jsapilist = ['onMenuShareTimeline', 'uploadVoice', 'addCard','chooseCard'];
                    res.jsApiList = jsapilist;
                    wx.config(res);
                },
                'json');
            $('#getcarda').click(function() {
                $.get('/api/wx/GetChooseCardParam',
                    function(res) {
                        console.log(res)
                        wx.chooseCard(res)
                    });
            });
            $('#getcard').click(function () {
                var cardid = ["pR19Cs5Vhza93rN6DDGRPwEojQOI", "pR19CsyEbxAkKLIQE346XJGp_th4", "pR19Cs6oG_snMR9S1dXIRiF7oMmA"];
                $.post('/api/wx/GetCardParams',
                    { cardid: cardid },
                    function (res) {
                        wx.addCard({
                            cardList: res,
                            success: function (res) {
                                console.log(res);
                            },
                            error: function (res) {
                                console.log(res);
                            }
                        })
                    });
            });
        })
    </script>
</body>
</html>